#pragma once

#include "d3d9.h"
#include "d3dx9.h"
#include "ModelManager.h"

// Add pragma comments so you do not have to change
// the property dependencies
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")

class Physics
{
private:
	// Singleton instance
	static Physics*		m_PhysicsInstance;
	// Pointer to the D3D Device
	IDirect3DDevice9*	m_Device;
	// Pointer to the model manager
	ModelManager*		m_pModelManager;

	// Boolean for gravity
	bool				bGravity;
	// Max point that the player is going to jump
	float				fMaxJump;
	// velocity control variables - have a constant max value and an every changing current value
	float				fMaxVel;
	float				fCurVelZ;
	float				fCurVelX;
	float				fCurRotZ; // rotate on Z when moving on the X axis
	float				fCurRotY; // rotate on Y when moving on the Z axis
	float				fMaxRot;
	float				fRotScalar;
	// collision delay - need a split second for player to get off the firewall
	long				lElapsedTime;
	long				lStartTime;
	long				lCurrentTime;
	bool				bRecentCollision;

public:
	Physics(void);
	~Physics(void);

	// Singleton functions
	static Physics* GetInstance(void);
	void DeleteInstance(void);
	// "Gravity checking"
	void InitializePhysics(IDirect3DDevice9* m_pD3DDevice);
	void GravityCheck(int iAmountTracks, float deltaTime, bool bJumpOn);
	bool GravityCheck(int iAmountTracks, int iTrack);
	bool Jump(float fDeltaTime);
	void FallingDown(float fDeltaTime);
	// Velocity functions
	void ResetVelocity(void);
	float GetCurVelX(void);
	float GetCurVelZ(void);
	void ChangeVelocityZPos(float fVelChange, float fDeltaTime);
	void ChangeVelocityZNeg(float fVelChange, float fDeltaTime);
	void ChangeVelocityXPos(float fVelChange, float fDeltaTime);
	void ChangeVelocityXNeg(float fVelChange, float fDeltaTime);
	void NegateVelocity(float fDeltaTime);
	void SlowVelocityZ(float fVelChange, float fDeltaTime);
	void SlowVelocityX(float fVelChange, float fDeltaTime);
};
